﻿using AutoMapper;
using MediatR;
using S.Archives.Domain.S.ArchivesDto;
using S.Archives.Infrstructre.InterFace;
using S.Archives.Read.Api.Application.Command;
using S.Common.Enums.Archives;

namespace S.Archives.Read.Api.Application.CommandHandlers
{
    public class SelMaleEmaleSelSZCommandHandler : IRequestHandler<SelMaleEmaleSelSZCommand, List<EnumStringDto>>
    {
        private readonly ISheepFileRepository sheepFileRepository;
        private readonly IMapper mapper;
        public SelMaleEmaleSelSZCommandHandler(ISheepFileRepository sheepFileRepository, IMapper mapper)
        {
            this.mapper=mapper;
            this.sheepFileRepository=sheepFileRepository;
        }
        public async Task<List<EnumStringDto>> Handle(SelMaleEmaleSelSZCommand request, CancellationToken cancellationToken)
        {
            var list = sheepFileRepository.GetAllAsync().Result;
          
                list = list.Where(x => x.FileType == 3).ToList();
          
            list = list.Where(x=>x.PresenceState==2).ToList();



            List<EnumStringDto> enumDto = new List<EnumStringDto>();
            enumDto = mapper.Map<List<EnumStringDto>>(list);
            return enumDto;
        }
    }
}
